package com.yuanduo_app.ui.map.view;

import android.os.Bundle;

import cn.ydxlm.maplib.entity.Location;
import cn.ydxlm.maplib.entity.Marker;
import cn.ydxlm.maplib.widget.MapView;
import com.xujl.fastlib.base.BaseView;
import com.xujl.fastlib.base.IControl;

import com.yuanduo_app.R;
import com.yuanduo_app.databinding.ActivityNearbyOilBinding;
import com.yuanduo_app.entity.NearbyOilLevelEntity;
import com.yuanduo_app.window.NearbyOilBottomWindow;

import java.util.List;


/**
 * <pre>
 *     author : xujl
 *     e-mail : 597355068@qq.com
 *     time   : 2019/08/20
 *     desc   :
 *     version: 1.0
 * </pre>
 */

public class NearbyOilActivityView extends BaseView<ActivityNearbyOilBinding> {
    private NearbyOilBottomWindow mOilBottomWindow;

    @Override
    public void init (IControl control) {
        mOilBottomWindow = new NearbyOilBottomWindow(control.exposeContext(), (NearbyOilBottomWindow.Callback) control);
        mBind.mapView.setOnMarkerClickListener((MapView.OnMarkerClickListener) control);
        mBind.mapView.setOnMapClickListener((MapView.OnMapClickListener) control);
    }

    public void setCenterPoint (Location location) {
        mBind.mapView.setCenterPoint(location);
    }

    public void showChooseOilLevel (List<NearbyOilLevelEntity> list) {
        mOilBottomWindow.showPopupWindow(list);
    }

    public void showNearStation (List<Marker> data) {
        mBind.mapView.addMarker(data, R.drawable.petrol_station, R.drawable.petrol_station_p);
    }

    @Override
    public void onResume () {
        super.onResume();
        mBind.mapView.onResume();
    }

    @Override
    public void onPause () {
        super.onPause();
        mBind.mapView.onPause();
    }

    @Override
    public void onDestroy () {
        super.onDestroy();
        mBind.mapView.onPause();
    }
    public void onCreate (Bundle bundle) {
        mBind.mapView.onCreate(bundle);
    }

    public void onSaveInstanceState (Bundle outState) {
        mBind.mapView.onSaveInstanceState(outState);
    }
}
